<?php 
ini_set("display_errors",1); 
$url = "http://docbao.com.vn/PagesMedia/thethao24h/20130506/7_tt24h_20130506_1.jpg";
$agent = $_SERVER['HTTP_USER_AGENT'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec ($ch);

$fp = fopen("image.jpg",'x');
fwrite($fp, $result); 
fclose($fp);
curl_close($ch);
/*function save_img($url){
	$exp = explode('/',$url);
	$lastIndex = sizeof($exp);
	if($data_s=file_get_contents($url,0))
	{
		$path="img/".$exp[$lastIndex-1];
		if(file_put_contents($path,$data_s)) echo "123";
	}
	return $path;
}
if($path = save_img('http://phim14.info/data/images/film/lac-vao-the-gioi-kien-the-ant-bully-2006.jpg'))
	 echo "thanh cong";*/
/*	 function renameImageToThumbnail($img){
		 $array = explode('.',$img);
		 $img = $array[0]."_thumbnail".$array[1];
		 return $img;
	 }
include('admin/SimpleImage.php');
$image = new SimpleImage();
$img='upload/sat-thu-mien-vien-tay-seraphim-falls-2006.jpg';
$image ->load($img);
$image ->resize(125,160);
$image ->save(renameImageToThumbnail($img));*/
/*function save_img($url){
	$exp = explode('/',$url);
	$lastIndex = sizeof($exp);
	if($data_s=file_get_contents($url,0))
	{
		$path="../upload/".$exp[$lastIndex-1];
		file_put_contents($path,$data_s);
	}
	return $path = "upload/".$exp[$lastIndex-1];
}
$url='http://nw8.upanh.com/b4.s37.d2/0795e639e71d9dd53ad8a528e88e7667_55022108.caubebienhinh2.jpg?rand=0.5991925143171102';
$exp=explode('?',$url);
$src = save_img($exp);*/
?>